package com.example.store2024.controller;

import com.example.store2024.model.Cart;
import com.example.store2024.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;
import java.util.Map;

@Controller
public class CarController {
    private CartService cartService;

    @Autowired
    public void setCartService(CartService cartService) {
        this.cartService = cartService;
    }

    @GetMapping("/cart")
    public String list(Map<String,Object> model){
        List<Cart> carts = this.cartService.findAll();
        model.put("cart",carts);
        return "cart";
    }
}
